home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2 Examples.sit
/
Raven 1.2 Examples
/
Quill
/
Source
/
WindowClickEditor.cpp
< prev
next >
Wrap
Text File
|
1997-02-20
|
7KB
|
226 lines
/*
* File: WindowClickEditor.h
* Summary: A view that knows how to edit a TWindow's clicking info.
* Written by: Jesse Jones
*
* Copyright ゥ 1996 Jesse Jones.
* For conditions of distribution and use, see copyright notice in ZTypes.h
*
* Change History (most recent first):
*
* <-> 12/24/96 JDJ Created
*/
#include "WindowClickEditor.h"
#include <ZTextBox.h>
// ===================================================================================
// class CEditWindowClickCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CEditWindowClickCommand::~CEditWindowClickCommand
//
//---------------------------------------------------------------
CEditWindowClickCommand::~CEditWindowClickCommand()
{
}
//---------------------------------------------------------------
//
// CEditWindowClickCommand::CEditWindowClickCommand
//
//---------------------------------------------------------------
CEditWindowClickCommand::CEditWindowClickCommand(TWindow* pane, const SWindowInfo& oldInfo, const SWindowInfo& newInfo) : Inherited(pane, oldInfo, newInfo)
{
}
//---------------------------------------------------------------
//
// CEditWindowClickCommand::UpdatePane
//
//---------------------------------------------------------------
void CEditWindowClickCommand::UpdatePane(const SWindowInfo& newInfo)
{
SWindowInfo info = mPane->GetInfo();
info.attr.layer = newInfo.attr.layer;
info.attr.handleClicks = newInfo.attr.handleClicks;
info.attr.targetable = newInfo.attr.targetable;
info.attr.clickThrough = newInfo.attr.clickThrough;
info.attr.getSelectClick = newInfo.attr.getSelectClick;
info.attr.hideOnSuspend = newInfo.attr.hideOnSuspend;
mPane->SetInfo(info);
}
#pragma mark -
// ===================================================================================
// CWindowClickEditor
// ===================================================================================
static TReanimatorRegister<CWindowClickEditor> sWindowClickEditorRegistrar;
//---------------------------------------------------------------
//
// CWindowClickEditor::~CWindowClickEditor
//
//---------------------------------------------------------------
CWindowClickEditor::~CWindowClickEditor()
{
}
//---------------------------------------------------------------
//
// CWindowClickEditor::CWindowClickEditor
//
//---------------------------------------------------------------
CWindowClickEditor::CWindowClickEditor(TView* superView) : Inherited(superView)
{
}
//---------------------------------------------------------------
//
// CWindowClickEditor::Create [static]
//
//---------------------------------------------------------------
MReanimatable* CWindowClickEditor::Create(MReanimatable* parent)
{
return new CWindowClickEditor(dynamic_cast<TView*>(parent));
}
//---------------------------------------------------------------
//
// CWindowClickEditor::OnReanimated
//
//---------------------------------------------------------------
void CWindowClickEditor::OnReanimated()
{
Inherited::OnReanimated();
TControl* control = nil;
control = dynamic_cast<TControl*>(this->FindSubPane("Layer"));
control->AddListener(this);
}
//---------------------------------------------------------------
//
// CWindowClickEditor::GetEditorInfo
//
//---------------------------------------------------------------
SWindowInfo CWindowClickEditor::GetEditorInfo() const
{
SWindowInfo info;
TControl* control = nil;
control = dynamic_cast<TControl*>(this->FindSubPane("Layer"));
if (control->GetValue() == 1)
info.attr.layer = kModalLayer;
else if (control->GetValue() == 2)
info.attr.layer = kFloatingLayer;
else
info.attr.layer = kRegularLayer;
control = dynamic_cast<TControl*>(this->FindSubPane("Handle Clicks"));
info.attr.handleClicks = control->GetValue();
control = dynamic_cast<TControl*>(this->FindSubPane("Targetable"));
info.attr.targetable = control->GetValue();
control = dynamic_cast<TControl*>(this->FindSubPane("Get Select Click"));
info.attr.getSelectClick = control->GetValue();
control = dynamic_cast<TControl*>(this->FindSubPane("Click Through"));
info.attr.clickThrough = control->GetValue();
control = dynamic_cast<TControl*>(this->FindSubPane("Hide on Suspend"));
info.attr.hideOnSuspend = control->GetValue();
return info;
}
//---------------------------------------------------------------
//
// CWindowClickEditor::SetEditorInfo
//
//---------------------------------------------------------------
void CWindowClickEditor::SetEditorInfo(const SWindowInfo& info)
{
TControl* control = nil;
control = dynamic_cast<TControl*>(this->FindSubPane("Layer"));
if (info.attr.layer == kModalLayer)
control->SetValue(1);
else if (info.attr.layer == kFloatingLayer)
control->SetValue(2);
else
control->SetValue(3);
control = dynamic_cast<TControl*>(this->FindSubPane("Handle Clicks"));
control->SetValue(info.attr.handleClicks);
control = dynamic_cast<TControl*>(this->FindSubPane("Targetable"));
control->SetValue(info.attr.targetable);
control->HandleEnable(info.attr.layer != kFloatingLayer, kRedraw);
control = dynamic_cast<TControl*>(this->FindSubPane("Get Select Click"));
control->SetValue(info.attr.getSelectClick);
control = dynamic_cast<TControl*>(this->FindSubPane("Click Through"));
control->SetValue(info.attr.clickThrough);
control = dynamic_cast<TControl*>(this->FindSubPane("Hide on Suspend"));
control->SetValue(info.attr.hideOnSuspend);
}
//---------------------------------------------------------------
//
// CWindowClickEditor::OnBroadcast (SControlMessage)
//
//---------------------------------------------------------------
void CWindowClickEditor::OnBroadcast(const SControlMessage& message)
{
SWindowInfo info = this->GetEditorInfo();
switch (message.value) {
case 1: // Modal
info.attr.layer = kModalLayer;
info.attr.targetable = true;
info.attr.hideOnSuspend = false;
break;
case 2: // Floating
info.attr.layer = kFloatingLayer;
info.attr.targetable = false;
info.attr.hideOnSuspend = true;
break;
case 3: // Regular
info.attr.layer = kRegularLayer;
info.attr.targetable = true;
info.attr.hideOnSuspend = false;
break;
default:
DEBUGSTR("Bogus value (%d) in CWindowClickEditor::OnBroadcast", message.value);
}
this->SetEditorInfo(info);
}